list comprehension hackerrank solution in python3